#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5+7;
char a[maxn], b[maxn];
int main() {
#ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
#endif
  int t; scanf("%d\n", &t);
  while(t--) {
    int ans = 0;
    int n; scanf("%d\n", &n);
    scanf("%s\n%s\n", b, a);
    for(int i=0; i<n; ++i) {
      if(a[i]=='1') {
        if(i!=0&&b[i-1]=='1') b[i-1]='0', ans++;
        else if(b[i]=='0') ans++;
        else if(i!=n-1&&b[i+1]=='1') b[i+1]='0', ans++;
      }
    }
    printf("%d\n", ans);
  }
}
